{template '_header'}
<div class='page-heading'><h2>投诉类别  {ifp 'sns.complain.category.edit'}<small>拖动可以排序</small>{/if}</h2></div>

  <form action="" method="post" class='form-validate'>

        <table class="table  table-responsive">
            <thead class="navbar-inner">
                <tr>
                    <th style="width:60px;">ID</th>
                    <th  style="width:200px;">类别名称</th>
                    <th style="width:80px;"></th>
                    <th></th>
                </tr>
            </thead>
            <tbody id='tbody-items'>
                {loop $list $row}
                <tr>
                    <td>
                        {$row['id']}
                      <input type="hidden" name="catid[]" value="{$row['id']}" >
                    </td>

                    <td>
                        {ifp 'sns.complain.category.edit'}
                           <input type="text" class="form-control" name="catname[]" value="{$row['name']}" >
                        {else}
                           {$row['name']}
                        {/if}
                    </td>
						<td>
							{ifp 'sns.complain.category.edit'}
						<input type="hidden" class="form-control" name="status[]" value="{$row['status']}">
						<label class='checkbox-inline' onclick="$(this).prev(':hidden').val( $(this).find(':checkbox').get(0).checked?'1':'0' ); ">
							<input type='checkbox' {if $row['status']==1}checked{/if}  /> 显示
						</label>
						{else}
							{if !empty($row['status'])}显示{else}隐藏{/if}
						{/if}
					</td>
                    <td>
                          {ifp 'sns.complain.category.delete'}
                          	<a href="{php echo webUrl('sns/complain/catedel', array('id' => $row['id']))}" data-toggle='ajaxRemove' class="btn btn-default btn-sm" data-confirm="确认删除此分类?"><i class="fa fa-trash"></i> 删除</a>
                          {/if}
                    </td>

                </tr>
                {/loop}
                 </tbody>
                <tr>
                    <td colspan="5">
                          {ifp 'sns.complain.category.edit'}
                            <input name="button" type="button" class="btn btn-default" value="添加类别" onclick='addCategory()'>
                            <input type="submit" class="btn btn-primary" value="保存类别">
                           {/if}
                    </td>
                </tr>


        </table>
        {$pager}


</form>
<script>

     {ifp 'sns.complain.category.edit'}
    require(['jquery.ui'],function(){
        $('#tbody-items').sortable();
    })
    {/if}

    function addCategory(){
         var html ='<tr>';
         html+='<td><i class="fa fa-plus"></i></td>';
         html+='<td>';
         html+='<input type="hidden" class="form-control" name="catid[]" value=""><input type="text" class="form-control" name="catname[]" value="">';
         html+='</td>';
         html+='<td>';
         html+='</td>';

         html+='<td></td></tr>';;
         $('#tbody-items').append(html);
    }
</script>

{template '_footer'}